<template>
  <div v-if="visible" class="loading-container">
    <van-loading type="spinner" color="#1989fa" size="36px">
      加载中...
    </van-loading>
  </div>
</template>

<script setup>
import { ref } from "vue";

const visible = ref(false);

// 对外暴露方法
const show = () => {
  visible.value = true;
};

const hide = () => {
  visible.value = false;
};

// 定义组件对外暴露的方法
defineExpose({
  show,
  hide,
});
</script>

<style scoped>
.loading-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgba(255, 255, 255, 0.8);
  z-index: 9999;
}
</style>
